/*

	Motivational regressions Transmission Model
	
	* Input: VA_GDP_Trade_wide_${sample}.dta
			 WorldTFPGrowth.dta
			 
	* Output: Regression tables

June/July 2022
Written by Pierre for Isabelle
Last modified: 29/06/2022
*/


			* Step 1 - Data Preparation

* Data on foreign affiliates
use "$datapathother/corres_Name_iso2_iso3_ifs", clear
duplicates drop iso2 iso3, force
sort iso2
save temp_iso2, replace


use "$datapathLifi/final_affiliate.dta", clear

* Keep our years, but first put a year ahead s.t. the MNE status is from previous year
replace year = year + 1
keep if year >= 1996 & year <= 2006

drop if siren == "."
drop if iso_affiliate == ""

keep siren year iso_affiliate
rename iso_affiliate iso2
duplicates drop
g Foreignaffiliate=1
drop if iso2 == "FR"
sort iso2
merge m:1 iso2 using temp_iso2
drop if _merge==2
drop if iso2==""
replace iso3="ROU" if iso3=="ROM"
g wiot=0
foreach i in $wiotcountry {
	replace wiot=1 if iso3=="`i'"
}
replace iso3="ROW" if wiot==0
collapse (max) Foreignaffiliate, by(siren iso3 year)
reshape wide Foreignaffiliate, i(siren year) j(iso3) string
g MNE1=1
label variable MNE1 "Siren has an affiliate in foreign country"
sort siren
save temp_lifi, replace

use "$datapathLifi/final_HQ.dta", clear

* Keep our years
replace year = year + 1
keep if year >= 1996 & year <= 2006

duplicates drop
keep siren iso_HQ year
drop if iso_HQ == ""
rename iso_HQ iso2

g ForeignHD=1
sort iso2
merge m:1 iso2 using temp_iso2
drop if _merge==2
erase temp_iso2.dta
drop if iso2==""
replace iso3="ROU" if iso3=="ROM"
g wiot=0
foreach i in $wiotcountry {
	replace wiot=1 if iso3=="`i'"
}
replace iso3="ROW" if wiot==0
collapse (max) ForeignHD, by(siren iso3 year)
reshape wide ForeignHD, i(siren year) j(iso3) string
g MNE2=1
label variable MNE2 "Siren has a HQ in foreign country"

sort siren
merge 1:1 siren year using temp_lifi
gen MNE=1
label variable MNE "Siren is part of a multinational company - siren*year specific"

drop _merge
sort siren
save "temp_lifi.dta", replace

* Data on REER
import excel "$datapathother/RBFRBIS.xls", sheet("FRED Graph") cellrange(A11:B361) firstrow clear
g t=_n
tsset t
g lRBFRBIS=log(RBFRBIS)
g growth = (RBFRBIS-l12.RBFRBIS)/l12.RBFRBIS
g dlog = lRBFRBIS-l12.lRBFRBIS
g year = 1994 if _n==1
g month=1 if _n==1
local j = 1994
local k=1
forvalues i=2(1)350{
	local k = `k'+1
	if `k'<=12{
		replace year= `j' if _n==`i'
		replace month=`k' if _n==`i'
	}
	if `k'>12{
		local k=1
		local j=`j'+1
		replace year= `j' if _n==`i'
		replace month=`k' if _n==`i'
	}
}
g yoy_growth_December = growth if month==12
g yoy_dlog_December = dlog if month==12
collapse (mean) yoy_growth_mean = growth yoy_dlog_mean = dlog (max)  yoy_growth_December yoy_dlog_December, by(year)
save temp_REER, replace

****************			
* Open data
cd "$outputpath"
use VA_GDP_Trade_wide_${sample}, clear

* Clean siren 
tostring siren, replace
gen temp = length(siren)
replace siren = "0" + siren if temp == 8
replace siren = "00" + siren if temp == 7
replace siren = "000" + siren if temp == 6
drop temp

* Merge with growth data
sort year
merge m:1 year using "$datapathother/WorldTFPGrowth"
drop if _merge==2
drop _merge

* Merge with REER data
sort year
merge m:1 year using "$temp_REER"
drop if _merge==2
drop _merge


* Merge with data on foreign affiliates
merge 1:1 siren year using "temp_lifi.dta"
replace MNE = 0 if MNE == .
replace MNE1 = 0 if MNE1 == .
replace MNE2 = 0 if MNE2 == .
replace MNE1 = 0 if MNE1 == 1 & MNE2 == 1
drop if _merge==2
drop _merge

* Set up panel
sort ID year
xtset ID year

* Take log of value added
* Note that VABCF is already a lag
gen ln_vabcf=ln(vabcf)

* Create interactions 
gen WorldGrowthFirmSize = gr_Real_GDPWorld*ln_vabcf
gen FranceGrowthFirmSize = _gr_Real_GDPFRA*ln_vabcf
gen WorldGrowthFirmSize_XM = WorldGrowthFirmSize*(export_intensity>0 & import_intensity>0)
gen WorldGrowthFirmSize_Xonly = WorldGrowthFirmSize*(export_intensity>0 & WorldGrowthFirmSize_XM==0)
gen WorldGrowthFirmSize_Monly = WorldGrowthFirmSize*(import_intensity>0 & WorldGrowthFirmSize_XM==0)
gen WorldGrowthFirmSize_D = WorldGrowthFirmSize*(WorldGrowthFirmSize_XM==0 & WorldGrowthFirmSize_Xonly==0 & WorldGrowthFirmSize_Monly==0)
gen WorldGrowthFirmSize_X = WorldGrowthFirmSize*(export_intensity>0 )
gen WorldGrowthFirmSize_M = WorldGrowthFirmSize*(import_intensity>0 )
gen WorldGrowthFirmSize_T = WorldGrowthFirmSize*(WorldGrowthFirmSize_XM!=0 | WorldGrowthFirmSize_Xonly!=0 | WorldGrowthFirmSize_Monly!=0)
gen WorldGrowthXD = gr_Real_GDPWorld*(export_intensity>0)
gen WorldGrowthMD = gr_Real_GDPWorld*(import_intensity>0)
gen REERMeanFirmSize = yoy_dlog_mean*ln_vabcf
gen REERDecemberFirmSize = yoy_dlog_December*ln_vabcf




g Growth_all_XDummy=0
g Growth_all_MDummy=0
g gr_Real_GDPROW=0
g gr_Real_GDPTWN=0
foreach i in $wiotcountry{
	 replace Growth_all_XDummy=Growth_all_XDummy+ gr_Real_GDP`i'*(export_intensity_`i'>0)
	 replace Growth_all_MDummy=Growth_all_MDummy+gr_Real_GDP`i'*(import_intensity_`i'>0)	
}

* Variables needed for Table A2 - Foreign affiliates data, and alternative dependent variables
gen MNE_Dummy=(MNE==1)
gen SizeMNE_Dummy = MNE_Dummy*ln_vabcf
g Growth_all_AF_Dummy=0
g Growth_all_HQ_Dummy=0
* I add capture, as some countries just never host a HQ
foreach i in $wiotcountry{
	 capture replace Growth_all_AF_Dummy=Growth_all_AF_Dummy+ gr_Real_GDP`i'*(Foreignaffiliate`i'>0)
	 capture replace Growth_all_HQ_Dummy=Growth_all_HQ_Dummy+gr_Real_GDP`i'*(ForeignHD`i'>0)	
}

* Create Dummies
gen X_Dummy=(export_intensity>0)
gen M_Dummy=(import_intensity>0)
gen XM_Dummy = (export_intensity>0 & import_intensity>0)
gen Xonly_Dummy = (export_intensity>0 & XM_Dummy!=1)
gen Monly_Dummy = (import_intensity>0 & XM_Dummy!=1)
gen D_Dummy = (XM_Dummy==0 & Xonly_Dummy==0 & Monly_Dummy==0)
gen T_Dummy = (XM_Dummy==1 | Xonly_Dummy==1 | Monly_Dummy==1)
gen SizeXM_Dummy = XM_Dummy*ln_vabcf
gen SizeXonly_Dummy = Xonly_Dummy*ln_vabcf
gen SizeMonly_Dummy = Monly_Dummy*ln_vabcf
gen SizeD_Dummy = D_Dummy*ln_vabcf
gen SizeX_Dummy = X_Dummy*ln_vabcf
gen SizeM_Dummy = M_Dummy*ln_vabcf
gen SizeT_Dummy = T_Dummy*ln_vabcf

* Generate fixed effects 
egen wiot_code = group(wiot12_jp)
egen wiot_year = group(wiot12_jp year)

* Drop crisis years
drop if year > 2006

* We want to run the regression on firms that have an observation for each year, i.e. when count == 11
bys ID: egen count=count(gr_vabcf_real)
drop if count != 11

* Trim LHS variables
* Clean our growth rate variable
sum gr_vabcf_real, d
winsor gr_vabcf_real, gen(bounds) p(0.0025)
cap drop sample
gen sample = 1
replace sample = 0 if bounds != gr_vabcf_real 
cap drop temp firm_treshold
* firm_treshold = 1 if growth rate is outside our bounds.
gen firm_treshold = 0
replace firm_treshold = 1 if sample == 0
bysort ID: gegen temp = mean(firm_treshold)
replace firm_treshold = 1 if temp != 0 & temp != .
drop temp

* Other dependent variables.
sum gr_saltrai_real, d
cap drop bounds
winsor gr_saltrai_real, gen(bounds) p(0.0025)
cap drop sample
gen sample = 1
replace sample = 0 if bounds != gr_saltrai_real 
cap drop temp firm_treshold_2
gen firm_treshold_2 = 0
replace firm_treshold_2 = 1 if sample == 0
bysort ID: gegen temp = mean(firm_treshold_2)
replace firm_treshold_2 = 1 if temp != 0 & temp != .
drop temp

sum gr_firm_inputs_real, d
cap drop bounds
winsor gr_firm_inputs_real, gen(bounds) p(0.0025)
cap drop sample
gen sample = 1
replace sample = 0 if bounds != gr_firm_inputs_real 
cap drop temp firm_treshold_3
gen firm_treshold_3 = 0
replace firm_treshold_3 = 1 if sample == 0
bysort ID: gegen temp = mean(firm_treshold_3)
replace firm_treshold_3 = 1 if temp != 0 & temp != .
drop temp

sum gr_firm_import_real, d
cap drop bounds
winsor gr_firm_import_real, gen(bounds) p(0.0025)
cap drop sample
gen sample = 1
replace sample = 0 if bounds != gr_firm_import_real 
cap drop temp firm_treshold_4
gen firm_treshold_4 = 0
replace firm_treshold_4 = 1 if sample == 0
bysort ID: gegen temp = mean(firm_treshold_4)
replace firm_treshold_4 = 1 if temp != 0 & temp != .
drop temp


			* Step 2 - Summary Statistics 

putexcel set "$outputpath/regression_Motivation_June2022_${sample}" , sheet("Summary Statistics") replace
putexcel A1=("June, 2022 - run by Pierre")
putexcel A2=("Summary Statistics of different samples after data cleaning/trimming") 
putexcel A3=("Based on wide data (an observation is a firm * year)") 
putexcel A4=("Balance-sheet data: $sample") 

* Prepare Table
putexcel B6=("\# of firms"), font([no]italic)
putexcel C6=("\# of observations"), font([no]italic)
putexcel D6=("Mean"), font([no]italic)
putexcel E6=("Median"), font([no]italic)
putexcel F6=("Min"), font([no]italic)
putexcel G6=("Max"), font([no]italic)
putexcel H6=("S.D."), font([no]italic)

putexcel A7=("Full Sample") , font([no]italic [no]bold)
putexcel A8=("$ d\ln Y_{f,m,j,t}$") 
putexcel A9=("$\ln Y_{f,m,j,t-1}$") 
putexcel A10=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A11=("$ d\ln Y_{W,t}$") 
putexcel A12=("Outliers") , font([no]italic [no]bold)
putexcel A13=("$ d\ln Y_{f,m,j,t}$") 
putexcel A14=("$\ln Y_{f,m,j,t-1}$") 
putexcel A15=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A16=("$ d\ln Y_{W,t}$") 
putexcel A17=("Clean Sample") , font([no]italic [no]bold)
putexcel A18=("$ d\ln Y_{f,m,j,t}$") 
putexcel A19=("$\ln Y_{f,m,j,t-1}$") 
putexcel A20=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A21=("$ d\ln Y_{W,t}$") 

* Number of firms
* Full sample
gen temp = 1
bysort ID: replace temp = . if _n != _N
sum temp
putexcel B8=`r(N)', nformat(###,###,###)
putexcel B9=`r(N)', nformat(###,###,###)
putexcel B10=`r(N)', nformat(###,###,###)
putexcel B11=`r(N)', nformat(###,###,###)
drop temp

* Outliers
gen temp = 1 if firm_treshold == 1
bysort ID: replace temp = . if _n != _N & firm_treshold == 1
sum temp if firm_treshold == 1
putexcel B13=`r(N)', nformat(###,###,###)
putexcel B14=`r(N)', nformat(###,###,###)
putexcel B15=`r(N)', nformat(###,###,###)
putexcel B16=`r(N)', nformat(###,###,###)
drop temp

* Clean sample
gen temp = 1 if firm_treshold == 0
bysort ID: replace temp = . if _n != _N & firm_treshold == 0
sum temp if firm_treshold == 0
putexcel B18=`r(N)', nformat(###,###,###)
putexcel B19=`r(N)', nformat(###,###,###)
putexcel B20=`r(N)', nformat(###,###,###)
putexcel B21=`r(N)', nformat(###,###,###)
drop temp

* Summary stats
* Full sample
sum gr_vabcf_real, d
putexcel C8=`r(N)', nformat(###,###,###)
putexcel D8=`r(mean)', nformat(0.000)
putexcel E8=`r(p50)', nformat(0.000)
putexcel F8=`r(min)', nformat(0.000)
putexcel G8=`r(max)', nformat(0.000)
putexcel H8=`r(sd)', nformat(0.000)
sum ln_vabcf, d
putexcel C9=`r(N)', nformat(###,###,###)
putexcel D9=`r(mean)', nformat(0.000)
putexcel E9=`r(p50)', nformat(0.000)
putexcel F9=`r(min)', nformat(0.000)
putexcel G9=`r(max)', nformat(0.000)
putexcel H9=`r(sd)', nformat(0.000)
sum WorldGrowthFirmSize, d
putexcel C10=`r(N)', nformat(###,###,###)
putexcel D10=`r(mean)', nformat(0.000)
putexcel E10=`r(p50)', nformat(0.000)
putexcel F10=`r(min)', nformat(0.000)
putexcel G10=`r(max)', nformat(0.000)
putexcel H10=`r(sd)', nformat(0.000)
sum gr_Real_GDPWorld, d
putexcel C11=`r(N)', nformat(###,###,###)
putexcel D11=`r(mean)', nformat(0.000)
putexcel E11=`r(p50)', nformat(0.000)
putexcel F11=`r(min)', nformat(0.000)
putexcel G11=`r(max)', nformat(0.000)
putexcel H11=`r(sd)', nformat(0.000)

* Outliers
sum gr_vabcf_real if firm_treshold == 1, d
putexcel C13=`r(N)', nformat(###,###,###)
putexcel D13=`r(mean)', nformat(0.000)
putexcel E13=`r(p50)', nformat(0.000)
putexcel F13=`r(min)', nformat(0.000)
putexcel G13=`r(max)', nformat(0.000)
putexcel H13=`r(sd)', nformat(0.000)
sum ln_vabcf if firm_treshold == 1, d
putexcel C14=`r(N)', nformat(###,###,###)
putexcel D14=`r(mean)', nformat(0.000)
putexcel E14=`r(p50)', nformat(0.000)
putexcel F14=`r(min)', nformat(0.000)
putexcel G14=`r(max)', nformat(0.000)
putexcel H14=`r(sd)', nformat(0.000)
sum WorldGrowthFirmSize if firm_treshold == 1, d
putexcel C15=`r(N)', nformat(###,###,###)
putexcel D15=`r(mean)', nformat(0.000)
putexcel E15=`r(p50)', nformat(0.000)
putexcel F15=`r(min)', nformat(0.000)
putexcel G15=`r(max)', nformat(0.000)
putexcel H15=`r(sd)', nformat(0.000)
sum gr_Real_GDPWorld if firm_treshold == 1, d
putexcel C16=`r(N)', nformat(###,###,###)
putexcel D16=`r(mean)', nformat(0.000)
putexcel E16=`r(p50)', nformat(0.000)
putexcel F16=`r(min)', nformat(0.000)
putexcel G16=`r(max)', nformat(0.000)
putexcel H16=`r(sd)', nformat(0.000)

* Clean sample
sum gr_vabcf_real if firm_treshold == 0, d
putexcel C18=`r(N)', nformat(###,###,###)
putexcel D18=`r(mean)', nformat(0.000)
putexcel E18=`r(p50)', nformat(0.000)
putexcel F18=`r(min)', nformat(0.000)
putexcel G18=`r(max)', nformat(0.000)
putexcel H18=`r(sd)', nformat(0.000)
sum ln_vabcf if firm_treshold == 0, d
putexcel C19=`r(N)', nformat(###,###,###)
putexcel D19=`r(mean)', nformat(0.000)
putexcel E19=`r(p50)', nformat(0.000)
putexcel F19=`r(min)', nformat(0.000)
putexcel G19=`r(max)', nformat(0.000)
putexcel H19=`r(sd)', nformat(0.000)
sum WorldGrowthFirmSize if firm_treshold == 0, d
putexcel C20=`r(N)', nformat(###,###,###)
putexcel D20=`r(mean)', nformat(0.000)
putexcel E20=`r(p50)', nformat(0.000)
putexcel F20=`r(min)', nformat(0.000)
putexcel G20=`r(max)', nformat(0.000)
putexcel H20=`r(sd)', nformat(0.000)
sum gr_Real_GDPWorld if firm_treshold == 0, d
putexcel C21=`r(N)', nformat(###,###,###)
putexcel D21=`r(mean)', nformat(0.000)
putexcel E21=`r(p50)', nformat(0.000)
putexcel F21=`r(min)', nformat(0.000)
putexcel G21=`r(max)', nformat(0.000)
putexcel H21=`r(sd)', nformat(0.000)

			* Step 3 - Regressions on clean sample
			* 3.1 - All regressions before storing on excel
* Table 1
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf gr_Real_GDPWorld if count==11 & firm_treshold == 0, cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf i.year if count==11 & firm_treshold == 0, cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf FranceGrowthFirmSize i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)

* Table 2
reg gr_saltrai_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold_2 == 0, cluster(ID)
reg gr_firm_inputs_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold_3 == 0, cluster(ID)
reg gr_firm_import_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold_4 == 0, cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf SizeMNE_Dummy MNE_Dummy i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf MNE1 MNE2 Growth_all_AF_Dummy Growth_all_HQ_Dummy i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)

* Table 3
reg gr_vabcf_real WorldGrowthFirmSize WorldGrowthMD WorldGrowthXD ln_vabcf M_Dummy X_Dummy i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize Growth_all_MDummy Growth_all_XDummy ln_vabcf M_Dummy X_Dummy i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize_D WorldGrowthFirmSize_T SizeD_Dummy SizeT_Dummy D_Dummy i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf REERDecemberFirmSize i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)

			* 3.2 - Store regressions
			
			* TABLE 1

* Prepare excel
putexcel set "$outputpath/regression_Motivation_June2022_${sample}" , sheet("Table 1") modify
putexcel B1=("(1)") 
putexcel D1=("(2)") 
putexcel F1=("(3)") 
putexcel H1=("(4)") 
putexcel A1=("Dep. Var.: d\ln Y_{f,m,j,t}") 
putexcel A2=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A4=("$\ln Y_{f,m,j,t-1}$")
putexcel A6=("$ d\ln Y_{W,t}$")
putexcel A8=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{FRA,t}$")
putexcel A10=("\# Observations")
putexcel A11=("\# years")
putexcel A12=("\# firms")
putexcel A13=("Adjusted $ R ^2$")
putexcel A14=("Fixed effects")


* TABLE 1 - (1)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf gr_Real_GDPWorld if count==11 & firm_treshold == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
if temp[4,3]<0.01{
	global p_gr_Real_GDPWorld "$^a$"
	}
else if temp[4,3]<0.05{
	global p_gr_Real_GDPWorld "$^b$"
	}
else if temp[4,3]<0.1{
	global p_gr_Real_GDPWorld "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_gr_Real_GDPWorld ""
	}	
	
* Store coeffs, ses and stars
putexcel B2=(_b[WorldGrowthFirmSize]) C2=("$p_WorldGrowthFirmSize") B3=(_se[WorldGrowthFirmSize]) B4=(_b[ln_vabcf]) C4=("$p_ln_vabcf") B5=(_se[ln_vabcf]) B6=(_b[gr_Real_GDPWorld]) C6=("$p_gr_Real_GDPWorld") B7=(_se[gr_Real_GDPWorld]), nform(0.000)

* Observations and R^2
putexcel B13=(e(r2_a)) B14=("-"), nform(0.000)
putexcel B10=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel B12=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel B11=(r(max))
drop _

* TABLE 1 - (2)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf i.year if count==11 & firm_treshold == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
	
	
* Store coeffs, ses and stars
putexcel D2=(_b[WorldGrowthFirmSize]) E2=("$p_WorldGrowthFirmSize") D3=(_se[WorldGrowthFirmSize]) D4=(_b[ln_vabcf]) E4=("$p_ln_vabcf") D5=(_se[ln_vabcf]), nform(0.000)

* Observations and R^2
putexcel D13=(e(r2_a)) D14=("Year"), nform(0.000)
putexcel D10=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel D12=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel D11=(r(max))
drop _

* TABLE 1 - (3)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	

* Store coeffs, ses and stars
putexcel F2=(_b[WorldGrowthFirmSize]) G2=("$p_WorldGrowthFirmSize") F3=(_se[WorldGrowthFirmSize]) F4=(_b[ln_vabcf]) G4=("$p_ln_vabcf") F5=(_se[ln_vabcf]), nform(0.000)

* Observations and R^2
putexcel F13=(e(r2_a)) F14=("Year $\times$ Sector"), nform(0.000)
putexcel F10=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel F12=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel F11=(r(max))
drop _

* TABLE 1 - (4)
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf FranceGrowthFirmSize i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
if temp[4,3]<0.01{
	global p_FranceGrowthFirmSize "$^a$"
	}
else if temp[4,3]<0.05{
	global p_FranceGrowthFirmSize "$^b$"
	}
else if temp[4,3]<0.1{
	global p_FranceGrowthFirmSize "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_FranceGrowthFirmSize ""
	}	
	
* Store coeffs, ses and stars
putexcel H2=(_b[WorldGrowthFirmSize]) I2=("$p_WorldGrowthFirmSize") H3=(_se[WorldGrowthFirmSize]) H4=(_b[ln_vabcf]) I4=("$p_ln_vabcf") H5=(_se[ln_vabcf]) H8=(_b[FranceGrowthFirmSize]) I8=("$p_FranceGrowthFirmSize") H9=(_se[FranceGrowthFirmSize]), nform(0.000)

* Observations and R^2
putexcel H13=(e(r2_a)) H14=("Year $\times$ Sector"), nform(0.000)
putexcel H10=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel H12=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel H11=(r(max))
drop _


			* TABLE A3

* Prepare excel
putexcel set "$outputpath/regression_Motivation_June2022_${sample}" , sheet("Table A3") modify
putexcel B1=("(1)") 
putexcel D1=("(2)") 
putexcel F1=("(3)") 
putexcel A1=("Dep. Var.: d\ln Y_{f,m,j,t}") 
putexcel A2=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A4=("$ IM_{f,t-1} \times d \ln Y_{W,t}$")
putexcel A6=("$ EX_{f,t-1} \times d \ln Y_{W,t}$")
putexcel A8=("$ d \ln Y_{W,t}^{IM}$") 
putexcel A10=("$ d \ln Y_{W,t}^{EX}$") 
putexcel A12=("$\ln Y_{f,m,j,t-1}$")
putexcel A14=("$ IM_{f,t-1}$")
putexcel A16=("$ EX_{f,t-1}$")
putexcel A18=("$ DOM_{f,t-1} \times $\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A20=("$ TRADE_{f,t-1} \times $\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A22=("$ DOM_{f,t-1} \times $\ln Y_{f,m,j,t-1}$") 
putexcel A24=("$ TRADE_{f,t-1} \times $\ln Y_{f,m,j,t-1}$") 
putexcel A26=("$ DOM_{f,t-1}$")

* Observations and co.
putexcel A28=("\# Observations")
putexcel A29=("\# years")
putexcel A30=("\# firms")
putexcel A31=("Adjusted $ R ^2$")

* TABLE A3 - (1) 
reg gr_vabcf_real WorldGrowthFirmSize WorldGrowthMD WorldGrowthXD ln_vabcf M_Dummy X_Dummy i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}
if temp[4,2]<0.01{
	global p_WorldGrowthMD "$^a$"
	}
else if temp[4,2]<0.05{
	global p_WorldGrowthMD "$^b$"
	}
else if temp[4,2]<0.1{
	global p_WorldGrowthMD "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_WorldGrowthMD ""
	}
if temp[4,3]<0.01{
	global p_WorldGrowthXD "$^a$"
	}
else if temp[4,3]<0.05{
	global p_WorldGrowthXD "$^b$"
	}
else if temp[4,3]<0.1{
	global p_WorldGrowthXD "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_WorldGrowthXD ""
	}
if temp[4,4]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,4]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,4]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,4]>=0.1{
	global p_ln_vabcf ""
	}
if temp[4,5]<0.01{
	global p_M_Dummy "$^a$"
	}
else if temp[4,5]<0.05{
	global p_M_Dummy "$^b$"
	}
else if temp[4,5]<0.1{
	global p_M_Dummy "$^c$"
	}
else if temp[4,5]>=0.1{
	global p_M_Dummy ""
	}
if temp[4,6]<0.01{
	global p_X_Dummy "$^a$"
	}
else if temp[4,6]<0.05{
	global p_X_Dummy "$^b$"
	}
else if temp[4,6]<0.1{
	global p_X_Dummy "$^c$"
	}
else if temp[4,6]>=0.1{
	global p_X_Dummy ""
	}	
	 
* Store coeffs, ses and stars
putexcel B2=(_b[WorldGrowthFirmSize]) C2=("$p_WorldGrowthFirmSize") B3=(_se[WorldGrowthFirmSize]), nform(0.000) 
putexcel B4=(_b[WorldGrowthMD]) C4=("$p_WorldGrowthMD") B5=(_se[WorldGrowthMD]), nform(0.000) 
putexcel B6=(_b[WorldGrowthXD]) C6=("$p_WorldGrowthXD") B7=(_se[WorldGrowthXD]), nform(0.000) 
putexcel B12=(_b[ln_vabcf]) C12=("$p_ln_vabcf") B13=(_se[ln_vabcf]), nform(0.000)
putexcel B14=(_b[M_Dummy]) C14=("$p_M_Dummy") B15=(_se[M_Dummy]), nform(0.000)
putexcel B16=(_b[X_Dummy]) C16=("$p_X_Dummy") B17=(_se[X_Dummy]), nform(0.000)

  
* Observations and R^2
putexcel B28=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel B30=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel B29=(r(max))
drop _
putexcel B31=(e(r2_a)), nform(0.000)

* TABLE A3 - (2) 
reg gr_vabcf_real WorldGrowthFirmSize Growth_all_MDummy Growth_all_XDummy ln_vabcf M_Dummy X_Dummy i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}
if temp[4,2]<0.01{
	global p_Growth_all_MDummy "$^a$"
	}
else if temp[4,2]<0.05{
	global p_Growth_all_MDummy "$^b$"
	}
else if temp[4,2]<0.1{
	global p_Growth_all_MDummy "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_Growth_all_MDummy ""
	}
if temp[4,3]<0.01{
	global p_Growth_all_XDummy "$^a$"
	}
else if temp[4,3]<0.05{
	global p_Growth_all_XDummy "$^b$"
	}
else if temp[4,3]<0.1{
	global p_Growth_all_XDummy "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_Growth_all_XDummy ""
	}
if temp[4,4]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,4]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,4]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,4]>=0.1{
	global p_ln_vabcf ""
	}
if temp[4,5]<0.01{
	global p_M_Dummy "$^a$"
	}
else if temp[4,5]<0.05{
	global p_M_Dummy "$^b$"
	}
else if temp[4,5]<0.1{
	global p_M_Dummy "$^c$"
	}
else if temp[4,5]>=0.1{
	global p_M_Dummy ""
	}
if temp[4,6]<0.01{
	global p_X_Dummy "$^a$"
	}
else if temp[4,6]<0.05{
	global p_X_Dummy "$^b$"
	}
else if temp[4,6]<0.1{
	global p_X_Dummy "$^c$"
	}
else if temp[4,6]>=0.1{
	global p_X_Dummy ""
	}	
	 
* Store coeffs, ses and stars
putexcel D2=(_b[WorldGrowthFirmSize]) E2=("$p_WorldGrowthFirmSize") D3=(_se[WorldGrowthFirmSize]), nform(0.000) 
putexcel D8=(_b[Growth_all_MDummy]) E8=("$p_Growth_all_MDummy") D9=(_se[Growth_all_MDummy]), nform(0.000) 
putexcel D10=(_b[Growth_all_XDummy]) E10=("$p_Growth_all_XDummy") D11=(_se[Growth_all_XDummy]), nform(0.000) 
putexcel D12=(_b[ln_vabcf]) E12=("$p_ln_vabcf") D13=(_se[ln_vabcf]), nform(0.000)
putexcel D14=(_b[M_Dummy]) E14=("$p_M_Dummy") D15=(_se[M_Dummy]), nform(0.000)
putexcel D16=(_b[X_Dummy]) E16=("$p_X_Dummy") D17=(_se[X_Dummy]), nform(0.000)

  
* Observations and R^2
putexcel D28=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel D30=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel D29=(r(max))
drop _
putexcel D31=(e(r2_a)), nform(0.000)

* TABLE A3 - (3) 
reg gr_vabcf_real WorldGrowthFirmSize_D WorldGrowthFirmSize_T SizeD_Dummy SizeT_Dummy D_Dummy i.wiot_year if count==11 & firm_treshold == 0 , cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize_D "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize_D "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize_D "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize_D ""
	}
if temp[4,2]<0.01{
	global p_WorldGrowthFirmSize_T "$^a$"
	}
else if temp[4,2]<0.05{
	global p_WorldGrowthFirmSize_T "$^b$"
	}
else if temp[4,2]<0.1{
	global p_WorldGrowthFirmSize_T "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_WorldGrowthFirmSize_T ""
	}
if temp[4,3]<0.01{
	global p_SizeD_Dummy "$^a$"
	}
else if temp[4,3]<0.05{
	global p_SizeD_Dummy "$^b$"
	}
else if temp[4,3]<0.1{
	global p_SizeD_Dummy "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_SizeD_Dummy ""
	}
if temp[4,4]<0.01{
	global p_SizeT_Dummy "$^a$"
	}
else if temp[4,4]<0.05{
	global p_SizeT_Dummy "$^b$"
	}
else if temp[4,4]<0.1{
	global p_SizeT_Dummy "$^c$"
	}
else if temp[4,4]>=0.1{
	global p_SizeT_Dummy ""
	}
if temp[4,5]<0.01{
	global p_D_Dummy "$^a$"
	}
else if temp[4,5]<0.05{
	global p_D_Dummy "$^b$"
	}
else if temp[4,5]<0.1{
	global p_D_Dummy "$^c$"
	}
else if temp[4,5]>=0.1{
	global p_D_Dummy ""
	}
	
* Store coeffs, ses and stars
putexcel F18=(_b[WorldGrowthFirmSize_D]) G18=("$p_WorldGrowthFirmSize_D") F19=(_se[WorldGrowthFirmSize_D]), nform(0.000) 
putexcel F20=(_b[WorldGrowthFirmSize_T]) G20=("$p_WorldGrowthFirmSize_T") F21=(_se[WorldGrowthFirmSize_T]), nform(0.000) 
putexcel F22=(_b[SizeD_Dummy]) G22=("$p_SizeD_Dummy") F23=(_se[SizeD_Dummy]), nform(0.000) 
putexcel F24=(_b[SizeT_Dummy]) G24=("$p_SizeT_Dummy") F25=(_se[SizeT_Dummy]), nform(0.000)
putexcel F26=(_b[D_Dummy]) G26=("$p_D_Dummy") F27=(_se[D_Dummy]), nform(0.000)
  
* Observations and R^2
putexcel F28=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel F30=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel F29=(r(max))
drop _
putexcel F31=(e(r2_a)), nform(0.000)

			
			* TABLE A2
	
* Prepare excel
putexcel set "$outputpath/regression_Motivation_June2022_${sample}" , sheet("Table A2") modify
putexcel B1=("(1)") 
putexcel D1=("(2)") 
putexcel F1=("(3)") 
putexcel H1=("(4)") 
putexcel J1=("(5)")
putexcel A2=("Dep. Var.:") 
putexcel B2=("Labor Costs") 
putexcel D2=("Input costs") 
putexcel F2=("Imported input costs") 
putexcel H2=("Value added") 
putexcel J2=("Value added")
putexcel A3=("$\ln Y_{f,m,j,t-1} \times d \ln Y_{W,t}$") 
putexcel A5=("$\ln Y_{f,m,j,t-1}$")
putexcel A7=("$ MNE_{f,t-1}$")
putexcel A9=("$ MNE_{f,t-1} \times d \ln Y_{W,t}$")
putexcel A11=("$ AF_{f,t-1}$")
putexcel A13=("$ HQ_{f,t-1}$")
putexcel A15=("$ d \ln Y_{f,W,t}^{AF}$")
putexcel A17=("$ d \ln Y_{f,W,t}^{HQ}$")
putexcel A19=("\# Observations")
putexcel A20=("\# years")
putexcel A21=("\# firms")
putexcel A22=("Adjusted $ R ^2$")
putexcel A23=("Fixed effects")

* TABLE A2 - (1) 
reg gr_saltrai_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold_2 == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
	
* Store coeffs, ses and stars
putexcel B3=(_b[WorldGrowthFirmSize]) C3=("$p_WorldGrowthFirmSize") B4=(_se[WorldGrowthFirmSize]), nform(0.000)
putexcel B5=(_b[ln_vabcf]) C5=("$p_ln_vabcf") B6=(_se[ln_vabcf]), nform(0.000)

* Observations and R^2
putexcel B22=(e(r2_a)) B23=("Year $\times$ Sector"), nform(0.000)
putexcel B19=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel B21=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel B20=(r(max))
drop _

* TABLE A2 - (2) 
reg gr_firm_inputs_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold_3 == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
	
* Store coeffs, ses and stars
putexcel D3=(_b[WorldGrowthFirmSize]) E3=("$p_WorldGrowthFirmSize") D4=(_se[WorldGrowthFirmSize]), nform(0.000)
putexcel D5=(_b[ln_vabcf]) E5=("$p_ln_vabcf") D6=(_se[ln_vabcf]), nform(0.000)

* Observations and R^2
putexcel D22=(e(r2_a)) D23=("Year $\times$ Sector"), nform(0.000)
putexcel D19=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel D21=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel D20=(r(max))
drop _

* TABLE A2 - (3) 
reg gr_firm_import_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold_4 == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
	
* Store coeffs, ses and stars
putexcel F3=(_b[WorldGrowthFirmSize]) G3=("$p_WorldGrowthFirmSize") F4=(_se[WorldGrowthFirmSize]), nform(0.000)
putexcel F5=(_b[ln_vabcf]) G5=("$p_ln_vabcf") F6=(_se[ln_vabcf]), nform(0.000)

* Observations and R^2
putexcel F22=(e(r2_a)) F23=("Year $\times$ Sector"), nform(0.000)
putexcel F19=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel F21=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel F20=(r(max))
drop _

* TABLE A2 - (4) 
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf MNE_Dummy SizeMNE_Dummy i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
if temp[4,3]<0.01{
	global p_MNE_Dummy "$^a$"
	}
else if temp[4,3]<0.05{
	global p_MNE_Dummy "$^b$"
	}
else if temp[4,3]<0.1{
	global p_MNE_Dummy "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_MNE_Dummy ""
	}	
if temp[4,4]<0.01{
	global p_SizeMNE_Dummy "$^a$"
	}
else if temp[4,4]<0.05{
	global p_SizeMNE_Dummy "$^b$"
	}
else if temp[4,4]<0.1{
	global p_SizeMNE_Dummy "$^c$"
	}
else if temp[4,4]>=0.1{
	global p_SizeMNE_Dummy ""
	}	
	
* Store coeffs, ses and stars
putexcel H3=(_b[WorldGrowthFirmSize]) I3=("$p_WorldGrowthFirmSize") H4=(_se[WorldGrowthFirmSize]), nform(0.000)
putexcel H5=(_b[ln_vabcf]) I5=("$p_ln_vabcf") H6=(_se[ln_vabcf]), nform(0.000)
putexcel H7=(_b[MNE_Dummy]) I7=("$p_MNE_Dummy") H8=(_se[MNE_Dummy]), nform(0.000)
putexcel H9=(_b[SizeMNE_Dummy]) I9=("$p_SizeMNE_Dummy") H10=(_se[SizeMNE_Dummy]), nform(0.000)


* Observations and R^2
putexcel H22=(e(r2_a)) H23=("Year $\times$ Sector"), nform(0.000)
putexcel H19=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel H21=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel H20=(r(max))
drop _

* TABLE A2 - (5) 
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf MNE1 MNE2 Growth_all_AF_Dummy Growth_all_HQ_Dummy i.wiot_year if count==11 & firm_treshold == 0, cluster(ID)

* Store stars
matrix temp = r(table)
if temp[4,1]<0.01{
	global p_WorldGrowthFirmSize "$^a$"
	}
else if temp[4,1]<0.05{
	global p_WorldGrowthFirmSize "$^b$"
	}
else if temp[4,1]<0.1{
	global p_WorldGrowthFirmSize "$^c$"
	}
else if temp[4,1]>=0.1{
	global p_WorldGrowthFirmSize ""
	}	
if temp[4,2]<0.01{
	global p_ln_vabcf "$^a$"
	}
else if temp[4,2]<0.05{
	global p_ln_vabcf "$^b$"
	}
else if temp[4,2]<0.1{
	global p_ln_vabcf "$^c$"
	}
else if temp[4,2]>=0.1{
	global p_ln_vabcf ""
	}	
if temp[4,3]<0.01{
	global p_MNE1 "$^a$"
	}
else if temp[4,3]<0.05{
	global p_MNE1 "$^b$"
	}
else if temp[4,3]<0.1{
	global p_MNE1 "$^c$"
	}
else if temp[4,3]>=0.1{
	global p_MNE1 ""
	}	
if temp[4,4]<0.01{
	global p_MNE2 "$^a$"
	}
else if temp[4,4]<0.05{
	global p_MNE2 "$^b$"
	}
else if temp[4,4]<0.1{
	global p_MNE2 "$^c$"
	}
else if temp[4,4]>=0.1{
	global p_MNE2 ""
	}	
if temp[4,5]<0.01{
	global p_Growth_all_AF_Dummy "$^a$"
	}
else if temp[4,5]<0.05{
	global p_Growth_all_AF_Dummy "$^b$"
	}
else if temp[4,5]<0.1{
	global p_Growth_all_AF_Dummy "$^c$"
	}
else if temp[4,5]>=0.1{
	global p_Growth_all_AF_Dummy ""
	}
if temp[4,6]<0.01{
	global p_Growth_all_HQ_Dummy "$^a$"
	}
else if temp[4,6]<0.05{
	global p_Growth_all_HQ_Dummy "$^b$"
	}
else if temp[4,6]<0.1{
	global p_Growth_all_HQ_Dummy "$^c$"
	}
else if temp[4,6]>=0.1{
	global p_Growth_all_HQ_Dummy ""
	}
	
	
* Store coeffs, ses and stars
putexcel J3=(_b[WorldGrowthFirmSize]) K3=("$p_WorldGrowthFirmSize") J4=(_se[WorldGrowthFirmSize]), nform(0.000)
putexcel J5=(_b[ln_vabcf]) K5=("$p_ln_vabcf") J6=(_se[ln_vabcf]), nform(0.000)
putexcel J11=(_b[MNE1]) K11=("$p_MNE1") J12=(_se[MNE1]), nform(0.000)
putexcel J13=(_b[MNE2]) K13=("$p_MNE2") J14=(_se[MNE2]), nform(0.000)
putexcel J15=(_b[Growth_all_AF_Dummy]) K15=("$p_Growth_all_AF_Dummy") J16=(_se[Growth_all_AF_Dummy]), nform(0.000)
putexcel J17=(_b[Growth_all_HQ_Dummy]) K17=("$p_Growth_all_HQ_Dummy") J18=(_se[Growth_all_HQ_Dummy]), nform(0.000)


* Observations and R^2
putexcel J22=(e(r2_a)) J23=("Year $\times$ Sector"), nform(0.000)
putexcel J19=(e(N)), nform(###,###,###)
egen _=group(ID) if e(sample)
sum _
putexcel J21=(r(max)), nform(###,###,###)
drop _
egen _=group(year) if e(sample)
sum _
putexcel J20=(r(max))
drop _

* TABLE A2 - Footnote 25
reg gr_vabcf_real WorldGrowthFirmSize ln_vabcf i.wiot_year if count==11 & firm_treshold == 0 & MNE_Dummy==0, cluster(ID)


